//package com.example.hotelsystem.interceptors;
//
//import com.auth0.jwt.interfaces.DecodedJWT;
//import com.example.hotelsystem.utils.JwtUtils;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.HashMap;
//import java.util.Map;
//
//public class JWTInterceptors implements HandlerInterceptor {
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        Map<String,Object> map = new HashMap<>();
//        String token = request.getHeader("token");
//        try {
//            JwtUtils.verify(token);
//            return true;
//        }catch (Exception e){
//            map.put("code",80401);
//            map.put("msg","请先登录");
//            map.put("data",null);
//            String json = new ObjectMapper().writeValueAsString(map);
//            response.setContentType("application/json;charset=UTF-8");
//            response.getWriter().println(json);
//            return false;
//
//        }
//    }
//}
